home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / comm2 / ipdilv19.rdm < prev    next >
Text File  |  1996-02-22  |  14KB  |  408 lines

  1. Short:    SLIP dialer; stdin/out terminal program
  2. Author:   wiedmann@neckar-alb.de
  3. Uploader: wiedmann@neckar-alb.de
  4. Type:     comm/tcp
  5.  
  6. IPDial - serial device communication program
  7. ============================================
  8.  
  9. IPDial is designed especially for creating a SLIP connection via the modem to a remote host: It can dial the remote hosts number, login into the host and initilize a SLIP connection. Configuring IPDi
  10. al is rather easy, as it reads its command from a textfile.
  11.  
  12. 1.) Disclaimer: Copyrights, (No) Warranty
  13. -----------------------------------------
  14.  
  15. This program is Copyright (C) 1994
  16.  
  17.     Jochen Wiedmann
  18.     Am Eisteich 9
  19.     72555 Metzingen
  20.     Germany
  21.  
  22.     Phone: (0049) +7123 / 14881
  23.     Mail: wiedmann@neckar-alb.de
  24.     
  25.     Modified with Jochen's OK
  26.     R. William Askew
  27.     askew@neosoft.com  // I found this easier to use than Rexx scripts
  28.                        // once the DSR error was corrected (I like it!!)
  29.  
  30. Permission is granted to make and distribute either verbatim and modified copies of this documentation and the program IPDial provided the copyright notice and this permission notice are preserved on
  31.  all copies and the "GNU General Public License" (in the file COPYING) is distributed as well.
  32.  
  33. The author gives ABSOLUTELY NO warranty that the program described in this documentation and the results produced by them are correct. The author cannot be held responsible for ANY damage resulting f
  34. rom the use of this software.
  35.  
  36. 2.) Installation
  37. ----------------
  38.  
  39. Rather simple. Just copy the program to a place in your path and edit the two files "login.script" and "hangup.script". (See Script file syntax below for details.)
  40.  
  41. You might want to enter the line
  42.  
  43.     IPDial login.script
  44.  
  45. at the beginning of AmiTCP's startnet script. Thus you get a SLIP connection by simply typing startnet.
  46.  
  47. Similar you could add the line
  48.  
  49.     IPDial hangup.script
  50.  
  51. at the bottom of the stopnet script.
  52.  
  53.  
  54. 3.) Invocation
  55. --------------
  56.  
  57. IPDial is started like this:
  58.  
  59.     IPDial SCRIPT,ECHO/S,VERBOSE/S,TERMINAL/S,DEVICE/K,PROTOCOL/K,
  60.     UNIT/K/N,BAUD/K/N,RAW/S
  61.  
  62. What IPDial does, depends on the TERMINAL switch: If this is active, the arguments DEVICE, UNIT, BAUD and PROTOCOL are used to open the serial.device. Once it is opened, the program acts as a very si
  63. mple terminal program. See the "terminal" command for an explanation of the RAW argument.
  64.  
  65. If TERMINAL is omitted, the given SCRIPT is read and the commands of the script are executed line by line. (See below) The argument ECHO instructs IPDial to print the modems replies to stdout, while 
  66. VERBOSE is used to show what the program's doing.
  67.  
  68. 4.) Script file syntax
  69. ----------------------
  70.  
  71. - Any line of the script file may contain only one command. In general command 
  72.   arguments are parsed with ReadArgs(), thus they may look like CLI command line
  73.   arguments: The characters "" may surround a string which contains blanks.
  74.  
  75.   Note, that ReadArgs() treats the character '*' as an escape sequence: Thus you
  76.   have to write
  77.  
  78.     ECHO "**"
  79.  
  80.   if you want to print a single '*'.
  81.  
  82. - Empty lines or lines beginning with a semicolon are assumed to be comments and
  83.   thus ignored.
  84.  
  85. - Lines may begin with a label, an alphanumeric word followed by a colon. Labels
  86.   are ignored, except that they may be used as destinations for "goto"          
  87.   instructions. (Anyone said BASIC? Yes, it is. :-) Labels are case-sensitive.
  88.  
  89. - This is the list of possible commands:
  90.  
  91.     DEVICE NAME/A,PROTOCOL,UNIT/K/N
  92.  
  93.       Opens the given device NAME with unit UNIT (Default 0).
  94.       This must be compatible to the serial.device. PROTOCOL
  95.       may be one of XONXOFF, RTSCTS, 7WIRE (Synonym for RTSCTS)
  96.       or NONE. Note that explicitly requesting a protocol
  97.       overwrites the defaults set by the Derial preferences
  98.       program.
  99.  
  100.       The DEVICE command should in general be the first command
  101.       of each script.
  102.  
  103.     SET BAUD/N/K,DATABITS/N/K,STOPBITS/N/K,BUFSIZE/N/K,PARITY/K
  104.  
  105.       This command is used to modify the serial.device parameters.
  106.       Note, that these overwrite the Serial preferences. Possible
  107.       parameters are:
  108.  
  109.       BAUD        baud rate
  110.       DATABITS    number of databits
  111.       STOPBITS    number of stopbits
  112.       BUFSIZE     read buffer size
  113.       PARITY      one of ODD, EVEN or NONE
  114.  
  115.     SHOWPARMS
  116.  
  117.       Writes the current serial.device settings to stdout.
  118.  
  119.     ECHO ARGS/M
  120.  
  121.       This will write the given ARGS to stdout. Note, that these
  122.       strings may contain patterns like \r (Carriage Return),
  123.       \n (Line Feed), \\ (Backslash :-) or \037 (octal digits,
  124.       representing the character ASCII 31.) The arguments are
  125.       separated by blanks, when they are printed.
  126.  
  127.  Sequences like $VAR or ${VAR} will be replaced with the  value of the environment variable VAR. (Empty string, if  VAR doesn't exist.) Use $$ to get the $ character itself.   Note, that $VAR will on
  128. ly work, if the name VAR consists of alphanumeric characters only and the name is separated with a non-alphanumeric character from the following. For example, $VAR+NAME means $VAR and not $VAR+NAME. 
  129. On the other hand $VARNAME means $VARNAME and not $VAR. (Obvious reason. :-)
  130.  
  131.  Note that ECHO does not write any Line Feeds or Carriage Returns unless you explicitly request it with the respective patterns.
  132.  
  133.     SEND ARGS/M
  134.  
  135.       This command sends the given strings to the serial.device
  136.       using DoIO(). These strings may contain the same patterns
  137.       as described with the ECHO command. Unlike ECHO the arguments
  138.       aren't separeted by blanks.
  139.  
  140.       See ECHO for a description of patterns that may be inserted
  141.       into SEND arguments.
  142.  
  143.     DELAY SECS/A
  144.  
  145.       Delays the given number of seconds. The value may contain a
  146.       fraction of seconds which is rounded to ticks: 0.5 means
  147.       25 ticks.
  148.  
  149.     WAIT TIMEOUT/K/N/A,ARGS/M
  150.  
  151.       This command waits until either one of the given strings
  152.       is read from the serial.device or the number of seconds
  153.       given by TIMEOUT has gone.
  154.  
  155.       A variable called STATUS indicates what happened: It contains
  156.       either -1 for timeout or the number of the string that was
  157.       read, beginning with 0. This variable may be used by the
  158.       ON statement.
  159.  
  160.       WAIT arguments are parsed like ECHO arguments. (See above.)
  161.  
  162.     SCAN FORMAT/A,GLOBAL/S,SAVE/S
  163.  
  164.       Used to scan the buffer read by the last "WAIT" command for
  165.       certain words. These may be used set environment variables.
  166.       The format string may contain the following patterns:
  167.  
  168.         %{WORD%} Ignores any characters until WORD is found in
  169.                  the buffer. Use %% to insert the '%' character
  170.                  into WORD.
  171.  
  172.         ' '      Ignores any number (including 0) and kind (blank,
  173.                  tab, line feed, carriage return, form feed) of
  174.                  white space characters.
  175.  
  176.      %[VAR%]%(SUFFIX%) Reads the next word from the buffer until
  177.                  the first white space character and stores it into
  178.                  the environment variable VAR.
  179.                  The optional SUFFIX is a sequence of characters
  180.                  to be removed from the end of the word.
  181.                  Any other characters in the format string are simply
  182.                  ignored.
  183.  
  184.  Usually environment variables are local (for IPDial and child processes only). Use the GLOBAL and SAVE keywords to store them in ENV: and ENVARC:, respectively. Note, that SAVE implies GLOBAL.
  185.  
  186.  Note, that you can use the SCAN command more than once on the same buffer.
  187.  
  188.  Example:
  189.  
  190.      SCAN "%{Your IP address is%} %[IPADDRESS]%%(.%)"
  191.  
  192.      Scans the buffer for a sentence like
  193.  
  194.   Your IP address is 145.2.1.34.
  195.  
  196.      and stores the value 145.2.1.34 into the variable IPADDRESS. Note, that the
  197.      character '.' is removed.
  198.  
  199.  The SCAN command stores the number of created environment variables in the STATUS variable, which can later be used by the ON command. Note, that the value -1 is never stored in the STATUS variable,
  200.  you have to use a dummy label in the
  201.  ON command.
  202.  
  203.     ON STATUS GOTO LABELS/M
  204.  
  205.       There's currently only one version of the ON command.
  206.       An ON command must follow a WAIT or SCAN command. ON reads
  207.       the value of the STATUS variable and jumps to the first
  208.       label, if STATUS is -1, to the second label, if STATUS is 0
  209.       and so on. A typical use of WAIT/ON looks like this:
  210.  
  211.         WAIT TIMEOUT=10 "Login:" "Busy"
  212.         ON STATUS GOTO TimeOut Login Busy
  213.  
  214.         TimeOut:
  215.         ECHO "Timeout happened, aborting.\n"
  216.         EXIT 10
  217.  
  218.         Busy:
  219.         ECHO "Remote busy, delaying...\n"
  220.         DELAY 25
  221.         ECHO "Trying again.\n"
  222.         GOTO DialAgain
  223.  
  224.         Login:
  225.          ;   Execute the login procedure
  226.  
  227.  You do not need to supply a label for any wait string: This will suppress jumping and instead continue on the next line.
  228.  
  229.     GOTO LABEL/A
  230.  
  231.       Jumps to the given label
  232.  
  233.     TERMINAL NOECHO/S,RAW/S,EOF
  234.  
  235.       Enters terminal mode: What you enter at the keyboard will
  236.       be sent to the serial.device and likewise the program will
  237.       display any input from the serial.device to you. The
  238.       TERMINAL command will be finished, if you enter EOF
  239.       (Ctrl-\).
  240.  
  241.       The NOECHO and EOF options can be used to enter a password,
  242.       if you don't like to include it into your login file: NOECHO
  243.       makes your input invisible and the EOF string terminates
  244.       terminal mode as soon, as you type in the first character
  245.       of the string. Thus you can do something like
  246.  
  247.         WAIT TIMEOUT=10 "Password:"
  248.         ON STATUS GOTO TimeOut Password
  249.  
  250.         Password:
  251.         ECHO "Enter login password: "
  252.         TERMINAL EOF="\n" NOECHO
  253.  
  254.       Usually you can send only complete lines to the modem,
  255.       especially this means that you have all editing capabilities
  256.       of the shell available. This is not the case in RAW mode:
  257.       Every character you type will be sent immediately to the
  258.       modem without any buffering or conversions.
  259.  
  260.       Notes:
  261.  
  262.           - You probably must put your modem into NOECHO mode too,
  263.             if you use the "terminal" command for entering a password.
  264.           - NOECHO mode implies RAW mode
  265.  
  266.     SYSTEM ARGS/M
  267.  
  268.       Executes the command given by ARGS. The arguments will be
  269.       parsed like ECHO and SEND arguments (you may insert
  270.       \ and $ patterns) and separated by blanks. The resulting
  271.       string will be executed. For example
  272.  
  273.         SYSTEM "Echo" "Hello!"
  274.  
  275.       will execute the command "Echo Hello!" and not "EchoHello!".
  276.  
  277.         EXIT RESULT
  278.  
  279.       Terminates the program, returns the given RESULT. (Defaults
  280.       to 0.)
  281.  
  282.     SETVAR NAME/A,VALUE/A,LOCALONLY/S,GLOBAL/S,SAVE/S
  283.  
  284.       Sets environment variable NAME to VALUE. If you set the
  285.       GLOBAL switch, your variable will be set in ENV: and not
  286.       in the programs local environment. The SAVE switch forces
  287.       copying to ENVARC:.
  288.  
  289.       Note, that SAVE implies GLOBAL.
  290.  
  291.        Commands are case-insensitive.
  292.  
  293. See the scripts Login.IPDial and Hangup.IPDial as examples.
  294.  
  295.  
  296. 5.) How to create a script file?
  297. --------------------------------
  298.  
  299. Enter the terminal mode. You should now be able to type commands like
  300.  
  301.     ATZ<return>
  302.  
  303. If all goes well, the modem should reply
  304.  
  305.     ATZ
  306.     OK
  307.  
  308. provided, that it is in echo mode. Now try to dial into your remote host with something like
  309.  
  310.     ATDP07071927920<return>
  311.  
  312. If the remote host's phone line isn't busy, you should eventually see the remote's login message. This message should explain what to do. Try it and log out. Now have a look at Login.IPDial, in gener
  313. al you should understand how to edit it.
  314.  
  315. 6.) Recommended Usage
  316. ---------------------
  317.  
  318. Each time you reconfigure AmiTCP, it will destroy your startnet script. Thus it is not a good idea to modify the startnet script.  Instead create a scriptfile, say "neton", which could look as follow
  319. s:
  320.  
  321.     .key ECHO/S,VERBOSE/S
  322.  
  323.     IPDial Work:lib/Login.script <ECHO> <VERBOSE>
  324.     If NOT WARN
  325.       startnet
  326.     EndIf
  327.  
  328. Likewise, create a script "netoff" like this
  329.  
  330.     stopnet
  331.     IPDial Work:lib/Hangup.IPDial
  332.  
  333. And, from now on, use "neton" and "netoff" instead of "startnet" and "stopnet".
  334.  
  335.  
  336. 7.) History
  337. -----------
  338.  
  339. I never expected IPDial to become a little bit popular. However, the number of questions and/or enhancement requests forced new versions: This is 1.6 now. Time for a history, as people might like to 
  340. know what's different.
  341.  
  342. V 1.1   23.11.94        Initial version
  343.  
  344. V 1.2   27.02.95        Added terminal mode
  345.    Now using ReadArgs() for command line parsing.
  346.  
  347. V 1.3   09.03.95        Added environment variable aupport to "send"
  348.    command. Added unit support.
  349.  
  350.    Suggested by Quarvon (Jürgen Lang)
  351.  
  352. V 1.4   21.04.95        Added "system" command.
  353.  
  354.    Suggested by Gutgolf (Michael Bauer)
  355.  
  356.    Added environment variable support to "echo"
  357.    command. Terminal mode now converts
  358.    LF to CR/LF, so that modem
  359.    recognizes commands.
  360.    (Let's hope, that will still
  361.    work for entering passwords. :-(
  362.  
  363. V 1.5   30.04.95        Added "scan" command.
  364.  
  365. V 1.6   26.06.95        "delay" command supporting ticks; ParseString()
  366.    supporting octal characters; "wait" command using
  367.    ParseString()
  368.  
  369.    Suggested by Will Bow.
  370.  
  371.    Fixed bug in SerialSend():
  372.    *.io_Device = *.io_Unit
  373.  
  374. V 1.7   21.07.95        Added NOECHO, RAW and EOF options to "terminal"
  375.    command.
  376.  
  377.    Suggested by Klaus Heinz
  378.  
  379.    Added BAUD option to command line.
  380.  
  381.    Added "setvar" command.
  382.  
  383. V 1.8   24.11.95        Added a delay() in the DeviceIODo() routine
  384.  
  385.   I have a A2500 with a GVP I/O card connected to a USR sportster v32.bis
  386.   modem.  
  387.   
  388.   I kept getting a no DSR error.
  389.   
  390.   This appears to be a timing problem.
  391.   
  392.   
  393.   status = DoIO(req->Req);
  394.   Delay(10);                   /* delay 10 ticks so modem has a chance */
  395.   return(status);
  396.   
  397.   Converted to compiled with SAS/C 6.xx
  398.   
  399.   Added some more VERBOSE ( for better or worse )
  400.   
  401.   
  402.   R. William Askew               A Harley Ride a Day
  403.                               Helps Drive the Blues Away
  404.  
  405. V 1.9   29.11.95         Fixed the DELAY command ( oops I broke it in v1.8
  406.  
  407.   
  408.